<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input id="text" type="text"></input>
</body>

</html>
<script>
    let dom = document.getElementById('text');
    dom.onkeyup = function () {
        console.log("键盘抬起");
    }
    dom.onkeydown = function () {
        console.log("键盘按下");
    }
    dom.onkeypress = function () {
        console.log("键盘按下并且不会捕获其他事件");
    }
</script>